/*
 * @Descripttion: 把react native 里的alert改了兼容三端
 */

import React from "react"
import { View, ViewStyle } from "react-native"
import { Modal } from "@ant-design/react-native"

const alert = Modal.alert
interface AlertProps {
  title: string
  message: string
  onPress: any
  text: string
  nativeID: string
}

interface AlertStyleProps {
  container: ViewStyle
}

const alertStyle: AlertStyleProps = {
  container: {
    backgroundColor: "rgba(0,0,0,.5)",
    bottom: 0,
    height: "50%",
    left: 0,
    position: "absolute",
    right: 0,
    top: 0,
    width: "100%",
    zIndex: 5000
  }
}

const WideAlert = (props: AlertProps): any => {
  let { title, message, text, onPress } = props
  return alert(`${title}`, `${message}`, [{ text, onPress }])
}

export function Alert(props: any) {
  return <View style={alertStyle.container}>{WideAlert(props)}</View>
}
